Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode single frame using GDCM #422

Merged
merged 5 commits into from
Nov 20, 2023
Merged

Conversation

dougyau
Copy link
Contributor

@dougyau dougyau commented Oct 7, 2023

Extending from the PR #421 when using GDCM to decode images it will load the whole image to memory. This PR implements the logic required to load only one image.

@dougyau dougyau marked this pull request as draft October 7, 2023 15:06
@dougyau dougyau changed the title [WIP] Decode single frame using GDCM Decode single frame using GDCM Oct 7, 2023
Copy link
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great follow-up on the new frame decoding feature, much appreciated!

I assume that this is still a work in progress, but I will leave some comments for now.

pixeldata/src/gdcm.rs Outdated Show resolved Hide resolved
.for_each(|fragment| buf.append(&mut fragment.clone()));
buf
} else {
fragments[frame].to_vec()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the frame comprises more than one fragment in a multi-frame pixel data fragment sequence? I do not think that we can make this assumption.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only single frame dicoms can have more than 1 fragment. Multi frame files, must be 1 fragment per frame. At least according to the standard.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can move forward with this assumption and revisit if we find a conflicting sample case. 👍

Copy link
Owner

@Enet4 Enet4 Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads-up, I received clarifications from DICOM WG6, who asserted that it is allowed for frames in a multi-frame instance to span through multiple fragments each, though more recent transfer syntaxes tend to disallow this.

Still, I won't make this a blocker so that these improvements can be delivered. The affected area is only for the integration with GDCM, which hopefully the project will depend less on over time.

pixeldata/src/gdcm.rs Outdated Show resolved Hide resolved
pixeldata/src/gdcm.rs Outdated Show resolved Hide resolved
pixeldata/src/gdcm.rs Outdated Show resolved Hide resolved
@dougyau
Copy link
Contributor Author

dougyau commented Oct 13, 2023

So far, I have tested this with Compressed (jpeg, jpeg-ls and j2k) and Uncompressed (little endian) data. With RGB, YBR_FULL_422, MONOCHROME1, MONOCRHOME2 and PALETTE_COLOR (at least decompressing) photometric interpretations.

@Enet4
Copy link
Owner

Enet4 commented Oct 29, 2023

Hello @dougyau! Are there any other pending concerns with this PR, so that it can be marked as ready?

@Enet4 Enet4 added A-lib Area: library C-pixeldata Crate: dicom-pixeldata labels Oct 29, 2023
@dougyau
Copy link
Contributor Author

dougyau commented Oct 29, 2023

This code is working, what I have to do is cover it with unit testing. I have been short of time, but once I do have some time, I will add the tests.

@dougyau
Copy link
Contributor Author

dougyau commented Nov 14, 2023

I have validated the existing test, and it uses the new code path. Of the test cases I believe we could convert SC_rgb_2frame.dcm to have a planar configuration = 1 to make it complete. How can I add this to the test-files repo?

@dougyau dougyau marked this pull request as ready for review November 14, 2023 22:38
@Enet4 Enet4 self-requested a review November 15, 2023 15:44
@Enet4
Copy link
Owner

Enet4 commented Nov 15, 2023

I have validated the existing test, and it uses the new code path. Of the test cases I believe we could convert SC_rgb_2frame.dcm to have a planar configuration = 1 to make it complete. How can I add this to the test-files repo?

I have been slowly working on a new release for the dicom-test-files crate (I am one of the owners at the moment) so that it supports more test files. You can send in a pull request to https://github.com/robyoung/dicom-test-files that adds a custom test file so that I can review it. The steps would be 1) copy the new file to a new data/custom/ folder, 2) run the script generate/generate.py to regenerate the file entries, and push the file plus the modified entries.rs.

Copy link
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with a few test files and could validate that the behavior has improved in accuracy and performance after these changes. I believe we are better off merging this now and reiterating on the test suite after dicom-test-files is updated. Thanks!

@Enet4 Enet4 merged commit a35752d into Enet4:master Nov 20, 2023
4 checks passed
@dougyau dougyau deleted the single-frame-gdcm branch January 6, 2024 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lib Area: library C-pixeldata Crate: dicom-pixeldata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants